package com.ruoyi.api.systext;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.CrmFeedback;
import com.ruoyi.system.domain.CrmSystemText;
import com.ruoyi.system.service.ICrmFeedbackService;
import com.ruoyi.system.service.ICrmSystemTextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sysText")
public class CrmSystemTextController {

    @Autowired
    private ICrmSystemTextService crmSystemTextServiceImpl;

    @Autowired
    private ICrmFeedbackService crmFeedbackServiceImpl;


    /**
     * 添加意见反馈
     * @return
     */
    @GetMapping("/setFeedback")
    public AjaxResult setFeedback(String content){
        if(StringUtils.isEmpty(content)){
            return AjaxResult.error("反馈失败,未填写反馈内容.");
        }
        CrmFeedback crmFeedback =new CrmFeedback();
        crmFeedback.setContent(content);
        int i = crmFeedbackServiceImpl.insertCrmFeedback(crmFeedback);
        return i > 0? AjaxResult.success("反馈成功"):AjaxResult.error("反馈失败");
    }


    /**
     * 获取app 系统数据  登出状态使用
     * @param type
     * @return
     */
        @GetMapping("/getSysText")
    public AjaxResult getSysText(Integer type){
        AjaxResult ajax = AjaxResult.success();
        CrmSystemText crmSystemText = crmSystemTextServiceImpl.selectCrmSystemTextByType(type);
        ajax.put("data",crmSystemText);
        return ajax;
    }

    /**
     * 获取app 系统数据  登出状态使用
     * @param type
     * @return
     */
    @GetMapping("/getSysTextLogin")
    public AjaxResult getSysTextLogin(Integer type){
        AjaxResult ajax = AjaxResult.success();
        CrmSystemText crmSystemText = crmSystemTextServiceImpl.selectCrmSystemTextByType(type);
        ajax.put("data",crmSystemText);
        return ajax;
    }
}
